import request from "../../request";

const api = {
    getPetals: '/admin/petals/all',
    update: '/admin/petals/update',
    save: '/admin/petals/save',
    deleteId: '/admin/petals/delete/id=',
    delbatch: '/admin/petals/del/batch',
    petalsById: '/admin/petals/get-petals/id=',
    petalsPage: '/admin/petals/page',
    children: '/admin/petals/find-children',
    admin: '/admin/petals/find-admin'
}

/**
 * 获取管理员数据
 * @returns {AxiosPromise}
 */
export function getAdminInfo(){
  return request({
      url: api.admin,
      method: 'GET',
  })
}

/**
 * 获取子女数据
 * @returns {AxiosPromise}
 */
export function getChildrenInfo(){
  return request({
      url: api.children,
      method: 'GET',
  })
}

/**
 * 添加
 * @param data
 * @returns {AxiosPromise}
 */
export function savePetalsData(param){
    return request({
        url: api.save,
        method: 'POST',
        data: param
    })
}

/**
 * 根据id进行删除
 * @returns {AxiosPromise}
 */
export function delPetalsByid(id){
  return request({
      url: api.deleteId + id,
      method: 'GET'
  })
}

/**
 * 批量删除
 * @param ids
 * @returns {AxiosPromise}
 */
export function delPetalsBatch(ids){
  return request({
      url: api.delbatch,
      method: 'POST',
      data: ids
  })
}

/**
 * 修改
 * @param data
 * @returns {AxiosPromise}
 */
export function updatePetals(param){
  return request({
      url: api.update,
      method: 'POST',
      data: param
  })
}

/**
 * 查询全部数据
 * @returns {AxiosPromise}
 */
export function getPetalsAllData(){
  return request({
      url: api.getPetals,
      method: 'GET',
  })
}

/**
 * 根据id进行查询
 * @returns {AxiosPromise}
 */
export function getPetalsByid(id){
  return request({
      url: api.petalsById + id,
      method: 'GET'
  })
}

/**
 * 分页查询
 * @param data
 * @returns {AxiosPromise}
 */
export function getPetalsPage(param){
  return request({
      url: api.petalsPage,
      method: 'GET',
      params: param
  })
}